<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加一个新的属性需要在在构造器函数中添加</title>
</head>

<body>
    <h2>JavaScript 对象</h2>
    <p id="demo"></p>
    <script>
        function Person(first, last, age, eye) {
            this.firstName = first;
            this.lastName = last;
            this.age = age;
            this.eyeColor = eye;
            this.nationality = "English";
        }

        var myFather = new Person("John", "Doe", 50, "blue");
        var myMother = new Person("Sally", "Rally", 48, "green");

        document.getElementById("demo").innerHTML =
            "我父亲的国籍是 " + myFather.nationality + "。我母亲的国籍是 " + myMother.nationality;
    </script>
</body>

</html>